<template>
  <div class="main-header">
    <div class="flod-icon">
      <el-icon size="30px">
        <component :is="isFlag ? 'Fold' : 'Expand'" @click="fnChange"></component>
      </el-icon>
    </div>
    <div class="header-content">
      <el-breadcrumb>
        <el-breadcrumb-item :to="{ path: '/' }">homepage</el-breadcrumb-item>
        <el-breadcrumb-item>promotion management</el-breadcrumb-item>
      </el-breadcrumb>
      <div class="content-info">
        <el-icon size="30"><ChatDotRound /></el-icon>
        <el-icon size="30"><Notification /></el-icon>
        <el-dropdown>
          <span class="el-dropdown-link">
            <img
              src="https://pic3.zhimg.com/v2-612276da224b9aae1b7096f1b3dcd80e_1440w.jpg"
              alt=""
              width="25px"
              height="25px"
              class="avatar"
            />
            <span>{{ (userInfo as any).userName }}</span>
            <el-icon class="el-icon--right">
              <arrow-down />
            </el-icon>
          </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item>修改密码</el-dropdown-item>
              <el-dropdown-item @click="fnLoginOut">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { ref } from "vue"
import useLoginStore from "@/store/login/login"
import { localCache } from "@/utils/cache"
const loginStore = useLoginStore()
let props = defineProps({
  isFlag: Boolean
})
let emit = defineEmits(["fnChangeFlag"])
let userInfo = ref({})
if (loginStore.userInfo) {
  // userInfo.value = JSON.parse(localCache.getCache("USERINFO"))
  userInfo.value = loginStore.userInfo
}
function fnLoginOut() {
  loginStore.fnLoginOut()
}
function fnChange() {
  emit("fnChangeFlag", !props.isFlag)
}
</script>
<style scoped lang="scss">
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 50px;
  color: #fff;
  .flod-icon {
    flex: 0 0 50px;
  }
  .header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1 1 auto;
    .el-breadcrumb {
      --el-text-color-primary: #fff;
      --el-text-color-regular: #fff;
    }
  }
  .content-info {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    .el-dropdown {
      :deep(.el-tooltip__trigger:focus) {
        outline: none;
      }
      .el-dropdown-link {
        display: flex;
        justify-content: center;
        align-items: center;
        color: #fff;
        gap: 5px;
      }
    }
  }
}
</style>
